package org.springframework.aop.aspectj;

import org.aopalliance.aop.Advice;
import org.springframework.aop.Pointcut;
import org.springframework.aop.PointcutAdvisor;

/**
 * aspectJ表达式的advisor
 *
 * @author derekyi
 * @date 2020/12/6
 */

//他是一个中间类，advice是顾问（或者代理的意思），里面的变量无非还是之前的
public class AspectJExpressionPointcutAdvisor implements PointcutAdvisor {

	//AspectJExpressionPointcutAdvisor==advisor

	//advisor==pointcut+advice

	private AspectJExpressionPointcut pointcut;//既然有pointcut，下面加一个字符串表达式也正常
	private Advice advice;
	private String expression;//切入点表达书




	public void setExpression(String expression) {
		//这里pointcut应该是自带的
		this.expression = expression;
	}


	@Override
	public Pointcut getPointcut() {
		if (pointcut == null) {
			//这构造方法就是之前说的，用来得到切入点的类的
			pointcut = new AspectJExpressionPointcut(expression);
		}
		return pointcut;
	}

	@Override
	public Advice getAdvice() {
		return advice;
	}

	public void setAdvice(Advice advice) {
		this.advice = advice;
	}
}
